#ifndef __EPOLLER_H__
#define __EPOLLER_H__

#include <sys/epoll.h>
#include <vector>
#include <unistd.h>
#include <assert.h>
#include <glog/logging.h>

class Epoller
{
public:
    Epoller(int maxEvent = 1024);
    ~Epoller();

    bool AddFd(int fd, uint32_t events);
    bool DelFd(int fd);
    bool ModFd(int fd, uint32_t events);

    int Wait(int timeoutMs = -1);

    int GetEventFd(int fd) const;
    uint32_t GetEvents(int fd) const;

private:
    int epollFd_;
    std::vector<epoll_event> events_;
};

#endif /* __EPOLLER_H__ */
